//
//  InformationView.m
//  phmall
//
//  Created by admin on 2017/12/20.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "InformationView.h"

@implementation InformationView

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.backgroundColor=[UIColor whiteColor];
        
        self.title=[[UILabel alloc]init];
        [self addSubview:self.title];
        self.title.font=[UIFont systemFontOfSize:15];
        self.title.text=Localized(@"详细信息");
        [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.offset(0);
            make.top.offset(0);
            make.height.offset(44);
        }];
        
        self.intro =[[UILabel alloc] init];
        self.intro.numberOfLines=0;
        self.intro.text=@"晒单理由:晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理单理由";
        self.intro.textColor=[UIColor colorWithHexString:@"#adadad"];
        self.intro.font=[UIFont systemFontOfSize:15];
        [self addSubview:self.intro];
        
        self.imageView=[[UIView alloc]init];
        [self addSubview:self.imageView];
       
    }
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    CGSize superSize = self.frame.size;
    
    if (CGSizeEqualToSize(superSize, CGSizeZero)) {
        return;
    }
    [self.intro mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.title.mas_bottom).offset(0);
        make.left.offset(10);
        make.width.offset(SCREEN_WIDTH-20);
    }];
}
-(void)setModel:(SupplyAndDemandDetailsModel *)model{
    _model=model;
    self.intro.text=[NSString stringWithFormat:@"%@:%@",Localized(@"详细信息"),self.model.detail];
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.equalTo(self.intro.mas_bottom).offset(10);
        make.height.offset((SCREEN_WIDTH-10)*self.imageArray.count);
    }];
    
    while ([self.imageView.subviews lastObject] != nil) {
        [(UIView*)[self.imageView.subviews lastObject] removeFromSuperview];  //删除并进行重新分配
    }
    for (int i=0; i<self.imageArray.count; i++) {
        UIImageView *img=[[UIImageView alloc]init];
        //        img.image=[UIImage imageNamed:@"图片"];
        img.contentMode=UIViewContentModeScaleAspectFill;
        img.backgroundColor=[UIColor redColor];
        [self.imageView addSubview:img];
        [img mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(10);
            //            make.right.offset(-10);
            make.height.width.mas_offset(SCREEN_WIDTH-20);
            make.top.offset(i*(SCREEN_WIDTH-10)+10);
        }];
    }
}
@end
